<template>
  <div class="race-box">
    <el-carousel height="300px" direction="vertical" :autoplay="true">
        <el-carousel-item v-for="item in dataList" :key="item.raceid">
            <el-image
            style="width: 100%; height: 300px"
            :src="require('@/assets/workImg/'+item.raceImg)"
            :preview-src-list="imgList"
            fit="cover"></el-image>
            <div class="block">
                <el-avatar shape="square" :size="50" :src="require('@/assets/avator/'+item.avatar)" style="margin-right: 5px;"></el-avatar>
                <div style="font-size: 18px; margin-right: 5px;">{{ item.username }}</div>
                <span>获赞数：</span><div style="font-size: 20px;color: red;">{{item.score}}</div>
            </div>
        </el-carousel-item>
    </el-carousel>
    <div class="sign-box" @click="handleSignIn">立即报名</div>
    <hr style="margin-top: 20px;margin-bottom: 20px;"/>

    <!-- 公益宣传等文章 -->
    <Title/>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';
import {GetTop3} from '@/request/api'
import Title from '@/components/title/title.vue'
export default {
  data(){
    return{
        imgList:[
            require('@/assets/blogImg/fish1.jpg'),
            require('@/assets/blogImg/fish2.jpg'),
            require('@/assets/blogImg/a.jpg')
        ],
        // squareUrl:require('@/assets/avator/admin.jpg')
        dataList:[],
        imgList:[]
    }
  },
  components:{
    Title
  },
  methods:{
    ...mapMutations({
      setIsShowNav: 'navStatus/setIsShowNav'
    }),
    handleSignIn(){
      this.$router.push('/race')
      this.setIsShowNav(false)
    }
  },
  async created(){
    let res = await GetTop3()
    this.dataList = res.data.data
    this.dataList.forEach(item =>{
      this.imgList.push(require('@/assets/workImg/'+item.raceImg))
    })
  }
}
</script>

<style scoped>
.race-box{
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}
.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .block{
    position: absolute;
    display: flex;
    flex-direction: row;
    vertical-align: middle;
    padding: 5px;
    height: 50px;
    line-height: 50px;
    bottom: 10px;
    right: 10px;
  }
.sign-box{
  width:100%;
  height: 30px;
  line-height: 30px;
  background-color: rgb(160,207,255);
  margin-top: 10px;
  border-radius: 5px;
  text-align: center;
  cursor: pointer;
}
.sign-box:hover{
  background-color: rgb(217,236,255);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
</style>
